package org.ns.longhttp.handler.asynchandler;

import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.TimeUnit;

public class DefaultUrlEventQueue extends AbstractUrlEventQueue {

    private LinkedBlockingDeque<String> urlQueue = new LinkedBlockingDeque<>();


    @Override
    protected void put(String url) {
        urlQueue.add(url);
    }

    @Override
    public String pop() {
        return urlQueue.pop();
    }

    @Override
    public String pull(int second) {
        try {
            return urlQueue.poll(second, TimeUnit.SECONDS);
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }

    @Override
    public int size() {
        return urlQueue.size();
    }
}
